import sys

from PySide6 import QtCore
from PySide6.QtWidgets import QApplication, QDialog, QProgressBar, QLabel, QVBoxLayout


class ProgressApp(QDialog):
    def __init__(self, title, message):
        super().__init__()
        self.msg = QLabel(message, self)
        self.progressBar = QProgressBar(self
                                        , minimum=0
                                        , maximum=0
                                        , alignment=QtCore.Qt.AlignmentFlag.AlignHCenter)
        # 设置进度条的样式表，使文本水平排列
        self.progressBar.setStyleSheet("""
            QProgressBar {
                text-align: center; /* 文本居中 */
            }
        """)
        layout = QVBoxLayout()
        layout.setContentsMargins(30, 20, 30, 20)

        layout.addWidget(self.msg, alignment=QtCore.Qt.AlignmentFlag.AlignCenter)
        layout.addWidget(self.progressBar)

        self.setLayout(layout)
        self.setWindowTitle(title)
        self.setWindowFlag(QtCore.Qt.WindowType.WindowCloseButtonHint, False)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = ProgressApp("进度", "无限制进度条")
    ex.show()
    sys.exit(app.exec())
